#!/bin/bash

# 设置默认的 BASE_URL
DEFAULT_BASE_URL="http://8.134.84.105:8080"

# 检查命令参数
if [ "$1" == "run" ]; then
    echo "Running in development mode with localhost..."
    flutter run --dart-define=BASE_URL=http://localhost:8888
elif [ "$1" == "build" ]; then
    # 如果提供了自定义的 BASE_URL，则使用它
    BASE_URL=${2:-$DEFAULT_BASE_URL}
    echo "Building with BASE_URL: $BASE_URL"
    flutter build ios --dart-define=BASE_URL=$BASE_URL
    echo "Build completed!"
else
    echo "Usage:"
    echo "  ./build.sh run     - Run in development mode with localhost"
    echo "  ./build.sh build   - Build for production with default URL"
    echo "  ./build.sh build 'http://custom-url:8080' - Build with custom URL"
fi 